package 每日一题;

import java.util.Scanner;

public class WY20两种排序方法 {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int num=sc.nextInt();
        String[] arr=new String[num];
        for (int i = 0; i <num; i++) {
            arr[i]=sc.next();
            //不能用 nextline()因为enter回车代表输入结束
        }

        if (isDir(arr) && isLen(arr)) {
            System.out.println("both");
        }else if (isLen(arr)) {
            System.out.println("lengths");
        }else if (isDir(arr)){
            System.out.println("lexicographically");
        }else {
            System.out.println("none");
        }
    }

    private static boolean isDir(String[] arr) {
        for (int i = 0; i <arr.length-1; i++) {
            //利用 String.compareTo()方法，arr[i].compareTo(arr[i+1])>0 代表 arr[i]大于(arr[i+1])的字典序
            if (arr[i].compareTo(arr[i+1])>0) {
                return false;
            }
        }
        return true;
    }

    private static boolean isLen(String[] arr) {
        for (int i = 0; i <arr.length-1; i++) {
            if (arr[i].length()<=arr[i+1].length()) {
                continue;
            }else {
                return false;
            }
        }
        return true;
    }
}
